<!DOCTYPE html>
<html lang="en">

<head>
    <title>历史记录</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        #list {
            margin: 1rem auto 0 auto;
        }
        li{
            list-style: none;
        }
        .date{
           color:blue;
           font-weight:600
        }
    </style>
</head>

<body>
    <a href="index.html">返回</a>
    <ul id='list'>

    </ul>

</body>
<script>

    (function () {
        let dataStr = localStorage.getItem('history'),
            data = dataStr ? JSON.parse(dataStr) : null

        if (!data) {
            list.innerHTML = '<li>没有打卡记录</li>'
        }

        let htmlStr = ''
        if (Array.isArray(data)) {
            data.forEach(d => {
                htmlStr += `
                    <li class="date"'>${d.date}</li>                    
                `
                if(d.records){
                    htmlStr += d.records.map(r=>`<li>${r}</li>`).join('')
                }
            })

            list.innerHTML = htmlStr
        }

    })()

</script>

</html>